﻿using System;

namespace OMC.DataManagement
{
    /// <summary>
    /// this is a MailContent, which represent a MailItem in Outlook
    /// </summary>
    /// <remarks>
    /// Copyright 2012 Stefan Lütolf
    /// </remarks>
    public class MailContent
    {
        private String Body;
        private String Subject;
        private String From;
        private String To;
        private static LuceneAnalyzer TheLuceneAnalyzer = new LuceneAnalyzer();

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="inBody">body of the mail</param>
        /// <param name="inSubject">subject of the mail</param>
        /// <param name="inFrom">sender adress of the mail</param>
        /// <param name="inTo">reciever adress of the mail</param>
        public MailContent(String inBody, String inSubject, String inFrom, String inTo)
        {
            this.Body = buildAnalyzedString(ref inBody);
            this.Subject = buildAnalyzedString(ref inSubject);
            this.From = buildAnalyzedString(ref inFrom);
            this.To = buildAnalyzedString(ref inTo);
        }

        /// <summary>
        /// to build a analyzed string using the apache.lucene analyzer
        /// </summary>
        /// <param name="inString">the String to analyze</param>
        /// <returns>the analyzed string</returns>
        private String buildAnalyzedString(ref String inString)
        {
            if (inString == null)
            {
                inString = "";
            }
            //return TheLuceneAnalyzer.analyzeString(inString);
            return inString;
        }

        /// <summary>
        /// to get the content of a MailContent object
        /// </summary>
        /// <returns>String of the Content</returns>
        public String getContent()
        {
            return Subject + ", " + Body; // +", " + From;
        }
    }
}